//
//  LSLiveCompetitionViewController.m
//  LookScore
//
//  Created by wr on 2018/3/20.
//  Copyright © 2018年 ChongQingXunTiCompany. All rights reserved.
//

#import "LSLiveCompetitionViewController.h"
#import "LSIntercontinentalMatchVController.h"
#import "LSRollingBallViewController.h"
#import "LSAnalyzeViewController.h"
#import "LSLiveViewController.h"
#import "LSExponentViewController.h"
#import "LSChatRoomViewController.h"
#import "ZJScrollPageView.h"
#import "LSLiveTopView.h"
#import "LSSocketManeger.h"
#import "LSMarchDetailModel.h"
#import "LSCompetitionModel.h"
#import "LSLiveModel.h"
#import "LSChatRoomModel.h"
#import "WRNavigationBar.h"
#import "LSLiveCompetitionNavView.h"
#import "MainTouchTableTableView.h"
#import "ParentClassScrollViewController.h"
#import <WebKit/WebKit.h>
#define NAVBAR_COLORCHANGE_POINT (IMAGE_HEIGHT - NAV_HEIGHT*2)
#define IMAGE_HEIGHT LSScareValue(200, LSScreenWidth)
#define NAV_HEIGHT 64
@interface LSLiveCompetitionViewController ()<ZJScrollPageViewDelegate,UITableViewDelegate,UITableViewDataSource,WKNavigationDelegate>

@property(strong, nonatomic)NSArray<NSString *> *titles;

@property(strong, nonatomic)NSArray<UIViewController<ZJScrollPageViewChildVcDelegate> *> *childVcs;

@property (nonatomic, strong) ZJScrollPageView *scrollPageView;
@property (nonatomic, strong) NSMutableArray * eventListArray;
@property (nonatomic, strong) NSMutableArray * reportListArray;
@property (nonatomic, strong) NSMutableArray * liveDataEventArray;
@property (nonatomic, strong) NSMutableArray * chatRoomArray;

@property(nonatomic ,strong)MainTouchTableTableView * mainTableView;
@property(nonatomic,strong) UIScrollView * parentScrollView;
/*
 * canScroll= yes : mainTableView 视图可以滚动，parentScrollView 禁止滚动
 */

@property (nonatomic, assign) BOOL canScroll;

@property (nonatomic, assign) BOOL isTopIsCanNotMoveMainTableView;
@property (nonatomic, assign) BOOL isTopIsCanNotMoveParentScrollView;
@property (nonatomic, strong) WKWebView * webView;
@property (nonatomic, strong) NSDictionary * dict;
@property (nonatomic, assign) BOOL isFinishWebview;
@property (nonatomic, strong) dispatch_source_t timer;
@end

@implementation LSLiveCompetitionViewController{
    LSLiveCompetitionNavView * navTopView;
    LSSocketManeger * manager;
    LSMarchDetailModel * marModel;
    LSLiveTopView *topView;
    LSLiveViewController *liveVC;
    LSChatRoomViewController *chatRoomVC;
    LSAnalyzeViewController *analyzeVC;
    LSRollingBallViewController *rollingBallVC;
}
@synthesize mainTableView;
- (NSMutableArray *)eventListArray{
    if (!_eventListArray) {
        _eventListArray = @[].mutableCopy;
    }
    return _eventListArray;
    
}
- (NSMutableArray *)reportListArray{
    
    if (!_reportListArray) {
        _reportListArray = @[].mutableCopy;
    }
    return _reportListArray;
    
}

- (NSMutableArray *)liveDataEventArray{
    
    if (!_liveDataEventArray) {
        _liveDataEventArray = @[].mutableCopy;
    }
    return _liveDataEventArray;
}
- (NSMutableArray *)chatRoomArray{
    
    if (!_chatRoomArray) {
        _chatRoomArray = @[].mutableCopy;
    }
    return _chatRoomArray;
}

- (void)viewWillAppear:(BOOL)animated{
   
    [super viewWillAppear:animated];
//    self.navigationController.navigationBar.translucent = YES;
//    [self wr_setNavBarBackgroundAlpha:0];
}
- (void)viewWillDisappear:(BOOL)animated{
    [super viewWillDisappear:animated];

    
}

- (void)viewDidLoad {
    [super viewDidLoad];
    [self.view addSubview:self.mainTableView];
    [self initUI];
    [self.view insertSubview:self.customNavBar aboveSubview:self.mainTableView];
    [self.customNavBar wr_setBottomLineHidden:YES];
    if (@available(iOS 11.0, *)) {
//        self.tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
    }
    // 设置导航栏显示图片
    self.customNavBar.barBackgroundImage = [UIImage imageNamed:@"liveBgImgae"];
    
    // 设置初始导航栏透明度
    [self.customNavBar wr_setBackgroundAlpha:0];
    navTopView = [[LSLiveCompetitionNavView alloc] initWithFrame:CGRectMake(0, 0, self.customNavBar.titleView.frame.size.width, self.customNavBar.titleView.frame.size.height)];
    [self.customNavBar.titleView addSubview:navTopView];
    
}
- (void)initUI{
    self.view.backgroundColor = LSTitleWhiteColor;
   
    //初始化顶部的view
    topView = [[LSLiveTopView alloc]initWithFrame:CGRectMake(0,-IMAGE_HEIGHT, LSScreenWidth, IMAGE_HEIGHT)];
    KWeakSelf(topView);
    KWeakSelf(self);
    topView.block = ^(UIButton *btn) {
        
        weakself.webView.hidden = NO;
        weaktopView.hidden = YES;
        [weakself.customNavBar wr_setRightButtonWithImage:[UIImage imageNamed:@"videos"]];
    };
    
    self.customNavBar.onClickRightButton = ^{
        MyLog(@"11");
        weakself.webView.hidden = YES;
        weaktopView.hidden = NO;
        [weakself.customNavBar wr_setRightButtonWithImage:nil];
    };
    
    [self.mainTableView addSubview:topView];

    manager = [LSSocketManeger shareManeger];
    //初始化分页
    self.childVcs = [self setupChildVc];
    self.mainTableView.bounces =  NO;
    if (@available(iOS 11.0, *)) {
        self.mainTableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
    }else {
        self.automaticallyAdjustsScrollViewInsets = NO;
    }
    
  

    self.canScroll = YES;
    [self loadData];
}

- (UIView *)setPageViewControllers{
    ZJSegmentStyle *style = [[ZJSegmentStyle alloc] init];
    //显示滚动条
    style.showLine = YES;
    // 颜色渐变
    style.gradualChangeTitleColor = YES;
    
    style.scrollLineColor=LSNavMainColor;
    
    style.segmentHeight=35;
    
    style.autoAdjustTitlesWidth=YES;
    
    style.normalTitleColor=[UIColor colorWithRed:255.f/255.f green:255.f/255.f blue:255.f/255.f alpha:1];
    
    style.selectedTitleColor=LSNavTitlenColor;
    
    style.scrollLineColor=LSNavTitlenColor;
    if (![[NSUserDefaults standardUserDefaults] boolForKey:@"isOk"]) {
        self.titles = @[@"圈子", @"分析",@"直播", @"指数",@"聊天室"];
    }else{
        self.titles = @[@"圈子", @"分析",@"直播",@"聊天室"];
    }

    // 初始化
    _scrollPageView = [[ZJScrollPageView alloc] initWithFrame:CGRectMake(0, 0, LSScreenWidth,LSScreenHeight-64) segmentStyle:style titles:self.titles parentViewController:self delegate:self];
    _scrollPageView.segmentView.backgroundColor=LSNavMainColor;
    [_scrollPageView setSelectedIndex:_selectIndex animated:NO];
    return _scrollPageView;
}

//- (void)initWithView{
//
//    ZJSegmentStyle *style = [[ZJSegmentStyle alloc] init];
//    //显示滚动条
//    style.showLine = YES;
//    // 颜色渐变
//    style.gradualChangeTitleColor = YES;
//
//    style.scrollLineColor=LSNavMainColor;
//
//    style.segmentHeight=35;
//
//    style.autoAdjustTitlesWidth=YES;
//
//    style.normalTitleColor=[UIColor colorWithRed:255.f/255.f green:255.f/255.f blue:255.f/255.f alpha:1];
//
//    style.selectedTitleColor=LSNavTitlenColor;
//
//    style.scrollLineColor=LSNavTitlenColor;
//
//
//    BOOL config = [[NSUserDefaults standardUserDefaults] boolForKey:@"isOk"];
//
//    self.titles = @[@"圈子", @"分析",@"直播", @"指数",@"聊天室"];
//
//    // 初始化
//    _scrollPageView = [[ZJScrollPageView alloc] initWithFrame:CGRectMake(0, 0, LSScreenWidth,LSScreenHeight -LSNavBarHeight) segmentStyle:style titles:self.titles parentViewController:self delegate:self];
//    _scrollPageView.segmentView.backgroundColor=LSNavMainColor;
//
//    [_scrollPageView setSelectedIndex:_selectIndex animated:NO];
//
////    ZJSegmentStyle *style = [[ZJSegmentStyle alloc] init];
////    //显示滚动条
////    style.showLine = YES;
////    // 颜色渐变
////    style.gradualChangeTitleColor = YES;
////
////    style.scrollLineColor=LSNavMainColor;
////
////    style.segmentHeight=35;
////
////    style.autoAdjustTitlesWidth=YES;
////
////    style.normalTitleColor=[UIColor colorWithRed:255.f/255.f green:255.f/255.f blue:255.f/255.f alpha:1];
////
////    style.selectedTitleColor=LSNavTitlenColor;
////
////    style.scrollLineColor=LSNavTitlenColor;
////
////    BOOL config = [[NSUserDefaults standardUserDefaults] boolForKey:@"isOk"];
////
////    self.titles = @[@"圈子", @"分析",@"直播", @"指数",@"聊天室"];
////
////    // 初始化
////    _scrollPageView = [[ZJScrollPageView alloc] initWithFrame:CGRectMake(0, 0, LSScreenWidth,LSScreenHeight -LSNavBarHeight) segmentStyle:style titles:self.titles parentViewController:self delegate:self];
////    _scrollPageView.segmentView.backgroundColor=LSNavMainColor;
////    [_scrollPageView setSelectedIndex:_selectIndex animated:NO];
//
////    [self.view addSubview:_scrollPageView];
////    return _scrollPageView;
////    return [UIView new];
//
//}

- (void)initWebView{
    //初始化WKWebViewConfiguration
    WKWebViewConfiguration * config = [[WKWebViewConfiguration alloc] init];
    //初始化wkwebview
    WKWebView * webView = [[WKWebView alloc] initWithFrame:CGRectMake(0,-IMAGE_HEIGHT, LSScreenWidth, IMAGE_HEIGHT) configuration:config];
    
    //    [config.userContentController addScriptMessageHandler:self name:@"showAnimate"];//往h5注入方法
    webView.hidden = YES;
    [self.mainTableView addSubview:webView];
    NSString * path = [[[NSBundle mainBundle] bundlePath]  stringByAppendingPathComponent:@"child.html"];//h5路径
    NSURLRequest * reuqest = [[NSURLRequest alloc] initWithURL:[NSURL fileURLWithPath:path]];
    [webView loadRequest:reuqest];
    webView.scrollView.scrollEnabled = NO;
    webView.multipleTouchEnabled = NO;
    webView.navigationDelegate = self;
    self.webView = webView;
    WKUserScript * wkUser = [[WKUserScript alloc] initWithSource:@"showAnimate" injectionTime:WKUserScriptInjectionTimeAtDocumentStart forMainFrameOnly:YES];
    [config.userContentController addUserScript:wkUser];
    
    // 获得队列
    dispatch_queue_t queue = dispatch_get_main_queue();
    // 创建一个定时器(dispatch_source_t本质还是个OC对象)
    self.timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, queue);
    
    // 设置定时器的各种属性（几时开始任务，每隔多长时间执行一次）
    // GCD的时间参数，一般是纳秒（1秒 == 10的9次方纳秒）
    // 何时开始执行第一个任务
    // dispatch_time(DISPATCH_TIME_NOW, 1.0 * NSEC_PER_SEC) 比当前时间晚3秒
    dispatch_time_t start = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC));
    uint64_t interval = (uint64_t)(1.0 * NSEC_PER_SEC);
    dispatch_source_set_timer(self.timer, start, interval, 0);
    
    // 设置回调
    dispatch_source_set_event_handler(self.timer, ^{
        MyLog(@"------------%@", [NSThread currentThread]);
        if (_isFinishWebview) {
            [self objcCallJsMethods:@[]];
            // 取消定时器
            dispatch_cancel(self.timer);
            self.timer = nil;
        }
        
    });
    // 启动定时器
    dispatch_resume(self.timer);
    
}

- (void)loadData{
    
    [LSHttpEnclosureTool GET:DATABASEMATCHDETAIL parameters:@{@"matchId":@(self.matchId)} resBlock:^(id responseObject) {
//        MyLog(@"---%@",responseObject);
        if (responseObject) {
            _dict = responseObject;
            [self initWebView];
            marModel = [LSMarchDetailModel mj_objectWithKeyValues:responseObject];
            
            topView.model = marModel;
            
            rollingBallVC.homeId = marModel.HomeTeamId;
            rollingBallVC.guestId = marModel.GuestTeamId;
            
            liveVC.model = marModel;
            
            analyzeVC.marModel = marModel;
            analyzeVC.leagueId = marModel.LeagueId;
            analyzeVC.homeId = marModel.HomeTeamId;
            analyzeVC.guestId = marModel.GuestTeamId;
            //        [self initWithView];
            
            navTopView.model = marModel;
            [self loadData1];
        }
    }];
    
}

- (void)loadData1{
    //加载socket地址
    [LSHttpEnclosureTool GET:LSWebSocketGetUrl parameters:@{@"type":@(self.matchId)} resBlock:^(id responseObject) {
//        MyLog(@"---%@",responseObject);
        if ([CommonClass isBlankString:responseObject] == NO) {
            //建立长连接
            [manager ls_open:responseObject connect:^{
                
            } receive:^(id message, LSSocketReceiveType type) {
                MyLog(@"%@",[CommonClass dictionaryWithJsonString:message]);
                //json字符串转字典
                NSDictionary * dict1 = [CommonClass dictionaryWithJsonString:message];
                NSDictionary * dict2 = [CommonClass dictionaryWithJsonString:dict1[@"Models"]];
                if ([dict1[@"Category"] integerValue] == 10) {
                        
                }else if([dict1[@"Category"] integerValue] == 3){
                    //事件统计时间树
                    NSArray * eventArr = dict2[@"MatchEventList"];
                    if(eventArr.count > 0){
                        [self.eventListArray removeAllObjects];
                        for (NSInteger i = [eventArr count] - 1; i>= 0; i--) {
                            NSDictionary * dict = eventArr[i];
                            LSEventList * model = [LSEventList mj_objectWithKeyValues:dict];
                            [self.eventListArray addObject:model];
                        }
                         liveVC.eventListArray = self.eventListArray;
                    }
                   //事件统计列表
                    if ([dict2[@"MatchReportList"] count] > 0){
                        NSMutableArray * reportArray = @[].mutableCopy;
                        for (NSDictionary *dict in dict2[@"MatchReportList"]) {
                            LSReportList * model = [LSReportList mj_objectWithKeyValues:dict];
                            [reportArray addObject:model];
                        }
                        self.reportListArray = [[NSMutableArray alloc] initWithObjects:reportArray, nil];
                        liveVC.reportListArray = self.reportListArray;
                    }
                }else if ([dict1[@"Category"] integerValue] == 1){
                    //文字直播
                    NSArray * flashArr = dict2[@"LiveFlashDataList"];
                    for (NSInteger i = 0; i< flashArr.count; i++) {
                        NSDictionary * dict = flashArr[i];
                        LSLiveDataEvent * model = [LSLiveDataEvent mj_objectWithKeyValues:dict];
//                        [self.liveDataEventArray addObject:model];
                        [self.liveDataEventArray insertObject:model atIndex:0];
                    }
                    liveVC.liveDataEventArray = self.liveDataEventArray;
                    [self objcCallJsMethods:flashArr.lastObject];
                }else if([dict1[@"Category"] integerValue] == 2){
                    for (NSDictionary * dict in dict2[@"ChatList"]) {
                        LSChatRoomModel * model = [LSChatRoomModel mj_objectWithKeyValues:dict];
                        [self.chatRoomArray addObject: model];
                    }
                    chatRoomVC.msgArray = self.chatRoomArray;
                }else if ([dict1[@"Category"] integerValue] == 4){
                    topView.dict = dict2;
                }
                   
            } failure:^(NSError *error) {
                MyLog(@"%@",error);
            }];
        }
    }];
    
}

#pragma mark -- WKNavigationDelegate
- (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation{
    _isFinishWebview = YES;
}
- (void)objcCallJsMethods:(NSArray *)array{
    //oc掉js的方法的时候 一定要跟你们前端配合好 
    NSDictionary * dict = @{@"info":_dict,
                            @"animate": array};
    //字典转json字符串
    NSString * jsonStr = [CommonClass convertToJsonData:dict];
    //去空格
    NSString * nospaceStr = [CommonClass noWhiteSpaceString:jsonStr];
    NSString * jsStr = [NSString stringWithFormat:@"showAnimate('%@')",nospaceStr];
//    MyLog(@"%@",jsStr);
    [self.webView evaluateJavaScript:jsStr completionHandler:^(id _Nullable response, NSError * _Nullable error) {
        MyLog(@"response = %@",response);
        MyLog(@"%@",error );
    }];

    
}

- (NSArray *)setupChildVc {
    //圈子
    rollingBallVC = [LSRollingBallViewController new];
    rollingBallVC.matchId = self.matchId;

    //分析
    analyzeVC = [LSAnalyzeViewController new];
    analyzeVC.matchId = self.matchId;
    analyzeVC.leagueId = self.leagueId;
    analyzeVC.homeId = self.homeId;
    analyzeVC.guestId = self.guestId;
    
    //直播
    liveVC = [LSLiveViewController new];
    liveVC.manager = manager;
    
    //指数
    LSExponentViewController *exponetVC = [LSExponentViewController new];
    exponetVC.macthId = self.matchId;
    
    //聊天室
    chatRoomVC = [LSChatRoomViewController new];
    chatRoomVC.manager = manager;
    
    NSArray *childVcs;
    if (![[NSUserDefaults standardUserDefaults] boolForKey:@"isOk"]) {
        childVcs = [NSArray arrayWithObjects:rollingBallVC,analyzeVC,liveVC,exponetVC,chatRoomVC, nil];
    }else{
        childVcs = [NSArray arrayWithObjects:rollingBallVC,analyzeVC,liveVC,chatRoomVC, nil];
    }
    
    
    return childVcs;
}
- (NSInteger)numberOfChildViewControllers {
    return self.titles.count;
}

- (UIViewController<ZJScrollPageViewChildVcDelegate> *)childViewController:(UIViewController<ZJScrollPageViewChildVcDelegate> *)reuseViewController forIndex:(NSInteger)index {
    
    UIViewController<ZJScrollPageViewChildVcDelegate> *childVc = reuseViewController;
    
    if (!childVc) {
        childVc = self.childVcs[index];
    }
    
    return childVc;
}

- (void)scrollPageController:(UIViewController *)scrollPageController childViewControllWillAppear:(UIViewController *)childViewController forIndex:(NSInteger)index{
//    MyLog(@"%ld",index);
    if ([[NSUserDefaults standardUserDefaults] boolForKey:@"isOk"]) {
        if (index == 4) {
            [UIView animateWithDuration:0.2 animations:^{
                self.parentScrollView.contentOffset = CGPointMake(0, 0);
                self.mainTableView.contentOffset = CGPointMake(0, -IMAGE_HEIGHT);
            } completion:^(BOOL finished) {
                
            }];
            self.mainTableView.scrollEnabled = NO;
        }else{
            self.mainTableView.scrollEnabled = YES;
        }
    }else{
        if (index == 3) {
            [UIView animateWithDuration:0.2 animations:^{
                self.parentScrollView.contentOffset = CGPointMake(0, 0);
                self.mainTableView.contentOffset = CGPointMake(0, -IMAGE_HEIGHT);
            } completion:^(BOOL finished) {
                
            }];
            self.mainTableView.scrollEnabled = NO;
        }else{
            self.mainTableView.scrollEnabled = YES;
        }
    }
    
    
    
}
- (BOOL)shouldAutomaticallyForwardAppearanceMethods {
    return NO;
}

- (void)updateFrame:(CGFloat )offsetY{

    if (-offsetY < IMAGE_HEIGHT){
        
        CGFloat alpha = (offsetY + IMAGE_HEIGHT) / LSNavBarHeight;
        [self.customNavBar wr_setBackgroundAlpha:alpha];

    }else{
        [self.customNavBar wr_setBackgroundAlpha:0];
    }
    
}
- (void)viewDidDisappear:(BOOL)animated{
    
    [super viewDidDisappear:animated];
    if (self.timer) {
        dispatch_cancel(self.timer);
        self.timer = nil;
    }

    [manager ls_close:^(NSInteger code, NSString *reason, BOOL wasClean) {
       
    }];
     manager.reconnectCounter = 0;
    
}


#pragma scrollDelegate
-(void)scrollViewLeaveAtTheTop:(UIScrollView *)scrollView{
    self.parentScrollView = scrollView;
    
    //离开顶部 主View 可以滑动
    self.canScroll = YES;
}

-(void)scrollViewChangeTab:(UIScrollView *)scrollView{
    self.parentScrollView = scrollView;
    /*
     * 如果已经离开顶端 切换tab parentScrollView的contentOffset 应该初始化位置
     * 这一规则 仿简书
     */
    if (self.canScroll) {
        self.parentScrollView.contentOffset = CGPointMake(0, 0);
    }
}

- (void)scrollViewDidScroll:(UIScrollView *)scrollView{
    
    /*
     *  处理联动事件
     */
    
    //获取滚动视图y值的偏移量
    CGFloat tabOffsetY = 0;
    CGFloat offsetY = scrollView.contentOffset.y;
    [self updateFrame:offsetY];
    if (offsetY >=IMAGE_HEIGHT) {
        
        scrollView.contentOffset = CGPointMake(0, tabOffsetY);
        offsetY = tabOffsetY;
    }
    
    self.isTopIsCanNotMoveParentScrollView = self.isTopIsCanNotMoveMainTableView;
    
    if (offsetY>=tabOffsetY) {
        scrollView.contentOffset = CGPointMake(0, tabOffsetY);
        self.isTopIsCanNotMoveMainTableView = YES;
    }else{
        self.isTopIsCanNotMoveMainTableView = NO;
    }
    
    if (self.isTopIsCanNotMoveMainTableView != self.isTopIsCanNotMoveParentScrollView) {
        if (!self.isTopIsCanNotMoveParentScrollView && self.isTopIsCanNotMoveMainTableView) {
            //滑动到顶端
            self.canScroll = NO;
        }
        
        if(self.isTopIsCanNotMoveParentScrollView && !self.isTopIsCanNotMoveMainTableView){
            //离开顶端
            if (!self.canScroll) {
                scrollView.contentOffset = CGPointMake(0, tabOffsetY);
            }else{
                self.parentScrollView.contentOffset = CGPointMake(0, tabOffsetY);
            }
        }
    }else
    {
        if (!self.canScroll){
            //支持下刷新,下拉时maintableView 没有滚动到位置 parentScrollView 不进行刷新
            CGFloat parentScrollViewOffsetY = self.parentScrollView.contentOffset.y;
            if(parentScrollViewOffsetY >0)
                self.parentScrollView.contentOffset = CGPointMake(0, 0);
        }else
        {
            self.parentScrollView.contentOffset = CGPointMake(0, 0);
        }
    }
    
    
    /**
     * 处理头部视图
     */
    //    CGFloat yOffset  = scrollView.contentOffset.y;
    //    if(yOffset < -headViewHeight) {
    //
    //        CGRect f = self.headImageView.frame;
    //        f.origin.y= yOffset ;
    //        f.size.height=  -yOffset;
    //        f.origin.y= yOffset;
    //
    //        //改变头部视图的fram
    //        self.headImageView.frame= f;
    //        CGRect avatarF = CGRectMake(f.size.width/2-40, (f.size.height-headViewHeight)+56, 80, 80);
    //        _avatarImage.frame = avatarF;
    //        _countentLabel.frame = CGRectMake((f.size.width-Main_Screen_Width)/2+40, (f.size.height-headViewHeight)+172, Main_Screen_Width-80, 36);
    //    }
}

#pragma mark --tableDelegate
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 1;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    return LSScreenHeight-LSNavBarHeight;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    [cell.contentView addSubview:[self setPageViewControllers]];
    
    return cell;
}

- (MainTouchTableTableView *)mainTableView{
    if (mainTableView == nil){
        mainTableView= [[MainTouchTableTableView alloc]initWithFrame:CGRectMake(0,0,LSScreenWidth,LSScreenHeight)];
        mainTableView.delegate=self;
        mainTableView.dataSource=self;
        mainTableView.showsVerticalScrollIndicator = NO;
        mainTableView.contentInset = UIEdgeInsetsMake(IMAGE_HEIGHT,0, 0, 0);
        mainTableView.backgroundColor = [UIColor clearColor];
    }
    return mainTableView;
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
